package cc.co.cutenimy.nimyexplore.ui.provider;

import java.lang.reflect.Array;
import java.util.Collection;

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;

/**
 * Help to convert every type instance to java array.
 * 
 * @author 234aini@gmail.com
 * 
 */
public class UniversalTreeContentProvier implements ITreeContentProvider {

	public void dispose() {

	}

	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {

	}

	public Object[] getElements(Object inputElement) {
		if (inputElement == null) {
			return null;
		}
		if (inputElement instanceof Array) {
			// return ((Array)inputElement).
		} else if (inputElement instanceof Collection) {
			return ((Collection<?>) inputElement).toArray(new Object[0]);
		}
		return null;
	}

	public Object[] getChildren(Object parentElement) {
		return null;
	}

	public Object getParent(Object element) {
		return null;
	}

	public boolean hasChildren(Object element) {
		return false;
	}

}
